#include "stdafx.h"
#include "MemoFile.h"

#include <sstream>
#include <iomanip>

#include "FileIterator.h"

std::wstring MemoFile::CreateName(const std::wstring &workingDir)
{
    SYSTEMTIME lTime;
    GetLocalTime(&lTime);

    std::wstringstream buff;
    buff.fill(L'0');

    buff << lTime.wYear 
        << std::setw(2) << lTime.wMonth 
        << std::setw(2) << lTime.wDay 
        << std::setw(2) << lTime.wHour 
        << std::setw(2) << lTime.wMinute 
        << std::setw(2) << lTime.wSecond;

    int count = CountFiles(workingDir, buff.str() + L"*.txt") + 1;

    buff << std::setw(3) << count 
        << L".txt";

    return buff.str();
}

MemoFile::MemoFile( const std::wstring& fileName, bool unicode )
    : FileName( fileName )
    , Unicode( unicode )
{}
